package yxy.game.pm2.chat.module;

import yxy.game.pm2.bean.PlayerBean;
import yxy.game.pm2.message.ChatMessage;
import yxy.game.pm2.module.player.PlayerHandle;

public class ChatMsgPlayer extends ChatMsg {
	// bean===========================================================================
	private String playerCode;

	public String getPlayerCode() {
		return playerCode;
	}

	public void setPlayerCode(String playerCode) {
		this.playerCode = playerCode;
	}

	@Override
	public ChatMessage.ChatMsg pack() {
		PlayerBean player = PlayerBean.get(getPlayerCode());

		ChatMessage.ChatMsg.Builder builder = ChatMessage.ChatMsg.newBuilder();
		if (player != null) {
			builder.setSource(new PlayerHandle().playerChatInfo(player));
		}
		builder.setText(getMsg());
		builder.setTime(getTime().getMillis());
		return builder.build();
	}

}
